package com.ssx.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ssx.entity.Customer;
import com.ssx.entity.Customershare;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ssx.entity.Employees;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ssx
 * @since 2020-10-24
 */
public interface CustomershareMapper extends BaseMapper<Customershare> {
    @Insert("insert into customershare(cusId,empid)values(#{customer.cusId},#{employees.empid})")
    @Override
    int insert(Customershare entity);

    @Select("select * from customershare ${ew.customSqlSegment}")
    @Results({
            @Result(
                    column = "cusId",
                    property = "customer",
                    javaType = Customer.class,
                    one = @One(select = "com.ssx.mapper.CustomerMapper.selectById")
            ),
            @Result(
                    column = "empid",
                    property = "employees",
                    javaType = Employees.class,
                    one = @One(select = "com.ssx.mapper.EmployeesMapper.selectById")
            )
    })
    @Override
    Customershare selectOne(@Param(Constants.WRAPPER)Wrapper<Customershare> queryWrapper);

    @Select("select customershare.* from customershare  ${ew.customSqlSegment}")
    @Results({
            @Result(
                    column = "cusId",
                    property = "customer",
                    javaType = Customer.class,
                    one = @One(select = "com.ssx.mapper.CustomerMapper.selectById")
            ),
            @Result(
                    column = "empid",
                    property = "employees",
                    javaType = Employees.class,
                    one = @One(select = "com.ssx.mapper.EmployeesMapper.selectById")
            )
    })
    @Override
    List<Customershare> selectList(@Param(Constants.WRAPPER)Wrapper<Customershare> queryWrapper);


}
